feat(audit): promote outcome / ip / userAgent to first-class AuditEvent fields#19
Merged
Merged
Conversation
…nt fields Follow-up to #15. That PR added the columns and the metadata-map fallback so publishers could record outcome/ip/userAgent without breaking the old SPI; this PR makes them first-class on the event record itself so new publishers don't have to use the metadata map. API additions ------------- - New AuditOutcome enum in audit-api: SUCCESS / FAILURE. Mirrors the values stored in platform_audit_log.outcome and surfaced in the admin UI's Audit Logs page. - AuditEvent record gains outcome, ip, userAgent fields. The canonical constructor accepts them; the original 5-arg constructor is kept as a backward-compatible delegation so every existing caller still compiles. - New AuditEvent.builder() — typed fluent builder for the eight field record, keeping the publish-site readable as the field count grows. Persistence ----------- - AuditLogService.record now reads outcome/ip/userAgent directly from the event record, falling back to the metadata-map convention from #15 when the first-class fields are null. Net effect: legacy publishers still work unchanged, new publishers use the builder. - Outcome strings (from either source) are normalised through AuditOutcome.valueOf so garbage values land as NULL — the response layer then treats them as SUCCESS, matching the pre-existing default-on-null behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up #1/5 to the contract-gap series. Closes the SPI debt #15 flagged: that PR added the columns and a metadata-map fallback so publishers could record
outcome/ip/userAgentwithout breaking the old SPI; this PR makes them first-class on the event record itself.Summary
API additions
AuditOutcomeenum inaudit-api:SUCCESS/FAILURE. Mirrors the values stored inplatform_audit_log.outcomeand surfaced in the admin UI.AuditEventrecord gainsoutcome,ip,userAgentfields. The canonical constructor accepts them; the original 5-arg constructor is preserved as a backward-compatible delegation so every existing caller still compiles unchanged.AuditEvent.builder()— typed fluent builder for the now-eight-field record, keeping publish-sites readable as the field count grows.Persistence
AuditLogService.recordreadsoutcome/ip/userAgentdirectly from the event record, falling back to the metadata-map convention from feat(audit-logs): paging + filters + outcome/ip/userAgent + field rename #15 when the first-class fields are null. Net effect: legacy publishers keep working, new publishers use the builder.AuditOutcome.valueOf, so garbage values land asNULL— the response layer then treats them asSUCCESS, matching the pre-existing "NULL == SUCCESS" default.Test plan
./gradlew buildgreen (55 tasks; all tests pass — no schema change, no breaking change to publishers)